import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:geomancy/styles/index.dart';
import 'package:go_router/go_router.dart';

class CalendarTabBar extends StatefulWidget {
  final TabController controller;
  final List<String> tabs;
  const CalendarTabBar({Key? key, required this.controller, required this.tabs}) : super(key: key);

  @override
  State<CalendarTabBar> createState() => _CalendarTabBarState();
}

class _CalendarTabBarState extends State<CalendarTabBar> {
  int _currentIndex = 0;

  @override
  void initState() {
    super.initState();
    _currentIndex = widget.controller.index;
  }


  @override
  Widget build(BuildContext context) {
    return Container(
      color: ColorStyle.pageDefaultColor,
      child: TabBar(
        controller: widget.controller,
        isScrollable: true,
        tabAlignment: TabAlignment.center,
        dividerHeight: 0,
        dividerColor: Colors.transparent,
        labelStyle: TextStyle(
          fontSize: 30.sp,
          fontWeight: FontWeight.bold
        ),
        labelColor: ColorStyle.textColor,
        labelPadding: EdgeInsets.symmetric(horizontal: 50.w),
        unselectedLabelColor: ColorStyle.themeLightColor,
        // unselectedLabelStyle: const TextStyle(
        //     fontWeight: FontWeight.normal
        // ),
        indicator: const BoxDecoration(),
        overlayColor: MaterialStateProperty.all(Colors.transparent),
        onTap: (int value) {
          _currentIndex = value;
        },
        tabs: widget.tabs.map((String tab) {
          return Tab(text: tab);
        }).toList(),
      ),
    );
  }
}
